const mongoose = require('mongoose')
const initRests = require('@root/InitDatas/restaurant.json')
const chalk = require('chalk')

const restaurantSchema = new mongoose.Schema({
    activities: [
      {
        attribute: String,
        description: String,
        icon_color: String,
        icon_name: String,
        id: Number,
        is_exclusive_with_food_activity: Boolean,
        name: String,
        tips: String,
        _type: Number
      },
    ],
    address: String,
    authentic_id: Number,
    description: String,
    distance: Number,
    favored: Boolean,
    flavors: [
      {
        id: Number,
        name: String
      }
    ],
    float_delivery_fee: Number,
    float_minimum_order_amount: Number,
    has_story: Boolean,
    id: Number,
    image_path: String,
    is_new: Boolean,
    is_premium: Boolean,
    is_stock_empty: Number,
    is_valid: Number,
    latitude: Number,
    longitude: Number,
    max_applied_quantity_per_order: Number,
    name: String,
    next_business_time: String,
    only_use_poi: Boolean,
    opening_hours: [
      String
    ],
    order_lead_time: Number,
    phone: String,
    piecewise_agent_fee: {
      description: String,
      extra_fee: Number,
      is_extra: Boolean,
      rules: [
        {
          fee: Number,
          price: Number
        }
      ],
      tips: String
    },
    platform: Number,
    posters: [],
    promotion_info: String,
    rating: Number,
    rating_count: Number,
    recent_order_num: Number,
    recommend: {
      image_hash: String,
      is_ad: Boolean,
      track: String
    },
    recommend_reasons: [
      {
        name: String
      },
    ],
    regular_customer_count: Number,
    scheme: String,
    status: Number,
    support_tags: [
      {
        border: String,
        color: String,
        icon: String,
        text: String,
        _type: Number
      }
    ],
    supports: [],
    theme: {
      default_color: String,
      header_style: Number,
      hongbao_style: Number,
      price_color: String,
      third_tab_name: String,
      vanish_fields: []
    },
    _type: Number
})

const restaurantModel = mongoose.model('restaurants', restaurantSchema)

// 初始化城市数据
// restaurantModel.insertMany(initRests, (err) => {
//   if (err) return console.log(
//     chalk.red(err)
//   )
//   console.log(
//     chalk.green("init restaurants successfully...")
//   )
// })

module.exports = restaurantModel
